package cate.game.pvp.championrace.data;


import cate.game.role.RoleSnapshot;
import lombok.Data;
import lombok.ToString;

@ToString
@Data
public class ChampionRaceOpponent {

    private int prRank;

    private RoleSnapshot snapshot;
    private long points;

    private int winCount;
    private int loseCount;

    public static ChampionRaceOpponent ofCopy(RoleSnapshot snapshot, long points) {
        return of(snapshot, points, true);
    }

    public static ChampionRaceOpponent ofNoCopy(RoleSnapshot snapshot, long points) {
        return of(snapshot, points, false);
    }

    public static ChampionRaceOpponent of(RoleSnapshot snapshot, long points, boolean copy) {
        ChampionRaceOpponent opponent = new ChampionRaceOpponent();
        opponent.setSnapshot(copy ? snapshot.copy() : snapshot);
        opponent.setPoints(points);
        return opponent;
    }

    public static ChampionRaceOpponent of(RoleSnapshot snapshot, long points, int prRank) {
        ChampionRaceOpponent eOpp = new ChampionRaceOpponent();
        eOpp.setSnapshot(snapshot);
        eOpp.setPrRank(prRank);
        eOpp.setPoints(points);
        return eOpp;
    }

    public void win(boolean count, long points) {
        if (count) {
            this.winCount++;
        }
        this.points += points;
    }

    public void lose(boolean count) {
        if (count) {
            this.loseCount++;
        }
    }
}
